#include "TextureFactory.h"
#include "Texture.h"
//
namespace Euclid
{
	TextureFactory::TextureFactory()
	{

	}

	TextureFactory::~TextureFactory()
	{

	}

	ITexture* TextureFactory::createEmptyTexture( unsigned int width, unsigned int height, D3DFORMAT pf )
	{
		Texture* tex = new Texture;
		if (NULL == tex)
		{
			return NULL;
		}

		//
		tex->createEmpty(width, height, pf);

		//
		return tex;
	}

	ITexture* TextureFactory::createTextureFromFile(const std::string& fileName )
	{
		Texture* tex = new Texture;
		if (NULL == tex)
		{
			return NULL;
		}

		//
		if (!tex->loadFromFile(fileName))
		{
			return NULL;
		}

		//
		return tex;
	}

	ITexture* TextureFactory::createTexFromMemory( unsigned char* buffer, unsigned int length )
	{
		Texture* tex = new Texture;
		if (tex)
		{
			if (!tex->loadFromMemory(buffer, length))
			{
				return NULL;
			}
		}
		return tex;
	}
}
